﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LabDayAtRaces
{
    public class Guy
    {
        
        public string Name; // The guy's name
        public Bet MyBet; // An instance of Bet that has his bet
        public int Cash; // How much he has

        //Guy's GUI controlls
        public RadioButton MyRadioButton;
        public Label MyLabel;
    
    
        public void UpdateLabels()
        {
            // Set my label to my bet's description and the label on my
            // radio button to show my cash ("Joe has 43 bucks")
            MyRadioButton.Text = Name + " has $" + Cash;
            MyLabel.Text = MyBet.GetDescription();

        }
        public void ClearBet()//reset bet and labels
        {
            MyBet = new Bet()
            {
                Amount = 0,
                Bettor = this
            };

        }
        public bool PlaceBet(int BetAmount, int DogToWin)
        {
            // Place a new bet and store it in myBet field
            // Return true if the guy had enough money to bet
            if (BetAmount <= Cash)
            {
                if (BetAmount >= Bet.minimumBet)
                {
                    MyBet = new Bet()
                    {
                        Amount = BetAmount,
                        Dog = DogToWin,
                        Bettor = this
                    };
                    return true;
                }
                else
                {
                    MessageBox.Show("The minimum Bet is " + Bet.minimumBet);
                    return false;
                }
            }
            else
            {
                MessageBox.Show(Name + " doesn't have enough money for this bet.");
                return false;
            }

        }
        public void collect(int Winner)
        {
            // Ask my bet to pay out, clear my bet, and update my labels
            Cash += MyBet.PayOut(Winner);
            ClearBet();
            UpdateLabels();
        }
    }
}
